package com.lu.widgets.demo;

import com.lu.widgets.R;
import com.lu.widgets.component.layout.ScrollLayout;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

public class ScrollLayoutTest extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.scroll_layout_demo);
		ScrollLayout ScrollLayoutTest = (ScrollLayout) findViewById(R.id.ScrollLayoutTest);
		RelativeLayout rl = new RelativeLayout(ScrollLayoutTest.this);
		rl.setBackgroundColor(Color.GRAY);
		ScrollLayoutTest.addView(rl);
		RelativeLayout rlMain = (RelativeLayout) findViewById(R.id.rlMain);
		rlMain.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Toast.makeText(ScrollLayoutTest.this, "hello",
						Toast.LENGTH_LONG).show();
			}
		});
		ListView lvMain = (ListView) findViewById(R.id.lvMain);
		lvMain.setAdapter(new BaseAdapter() {
			private String[] strs = new String[] { "1", "2", "3", "4", "5",
					"6", "7", "8", "9", "10" };

			@Override
			public View getView(int position, View convertView, ViewGroup parent) {
				if (convertView == null) {
					convertView = new TextView(ScrollLayoutTest.this);
				}
				TextView tv = (TextView) convertView;
				tv.setText(strs[position]);
				tv.setHeight(120);
				return convertView;
			}

			@Override
			public long getItemId(int position) {
				// TODO Auto-generated method stub
				return position;
			}

			@Override
			public Object getItem(int position) {
				// TODO Auto-generated method stub
				return strs[position];
			}

			@Override
			public int getCount() {
				// TODO Auto-generated method stub
				return strs.length;
			}
		});
	}
}